package com.ease.context.ioc;

import com.ease.common.util.Detect;

/**
 * 
 * @author nathanleewei
 * 
 */
public abstract class AbstractDynamicBean extends Detect {

	protected String beanName;

	public AbstractDynamicBean(String beanName) {
		this.beanName = beanName;
	}

	public String getBeanName() {
		return beanName;
	}

	public void setBeanName(String beanName) {
		this.beanName = beanName;
	}

	/**
	 * 获取bean 的xml描述
	 * 
	 * @return
	 */
	protected abstract String getBeanXml();

	/**
	 * 生成完整的xml字符串
	 * 
	 * @return
	 */
	public String getXml() {
		StringBuffer buf = new StringBuffer();
		buf.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>")
				.append("<beans xmlns=\"http://www.springframework.org/schema/beans\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"")
				.append("       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd\" default-lazy-init=\"true\">").append(getBeanXml())
				.append("</beans>");
		return buf.toString();
	}
}
